<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 网站管理 <span class="c-gray en">&gt;</span> 链接管理<span class="c-gray en">&gt;</span> 修改链接</nav>
	<div id="sectionContent" class="Hui-article">
		<article class="page-container">
			<div class="form form-horizontal" id="form-admin-add">
        <input type="hidden" id="linkId" v-model="content.id"/>
        <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>类型：</label>
					<div class="formControls col-xs-8 col-sm-9">
            <select class="select" id="linkType"></select>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>标题：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="title" name="title" v-model="content.title">
					</div>
				</div>
        <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>图标：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="icon" name="icon" v-model="content.icon">
					</div>
				</div>
        <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>地址：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="uri" name="uri" v-model="content.uri">
					</div>
				</div>
        <div class="row cl">
					<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>排序：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" id="sorting" name="sorting" value="1" v-model="content.sorting">
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary" type="button" v-on:click="saveData()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" style="margin-right:30px;">
						<input class="btn" type="button" onclick="javascript:history.go(-1)" value="&nbsp;&nbsp;取消&nbsp;&nbsp;">
					</div>
				</div>
			</div>
		</article>
	</div>
  <script>
        new Vue({
            el:'#sectionContent',
            http: authorization(),
            data:{
                content:{}
            },
            created:function(){
                this.$http.get('/restful/cms/v1.0/link/'+getQueryString('id')).then((response) => {
                    this.content = responseObj(response).data;
                    var result = responseObj(response).data;
                    this.$http.get('/restful/base/v1.0/syscnf/dicts/CMS_LINK_TYPE').then((response) => {
                        var modules = responseObj(response).data;
                        modules.forEach(function(obj){
                          if(obj.code == result.linkType){
                            $('#linkType').append("<option value='"+obj.code+"' selected>"+obj.name+"</option>");
                          }else{
                            $('#linkType').append("<option value='"+obj.code+"'>"+obj.name+"</option>");
                          }
                        });
                    }).catch(function(response) {
                        alert(errorMsg(response));
                    });
                }).catch(function(response) {
                    alert(errorMsg(response));
                });
            },
            methods:{
                backToList:function(){
                    window.parent.location.href="#!view/cms/link/link-list.html?"+Math.random();
                },
                saveData:function(){
                    var formData = {
                      title:$('#title').val(),
                      sorting:$('#sorting').val(),
                      title:$('#title').val(),
  										uri:$('#uri').val(),
                      icon:$('#icon').val(),
                      linkType:$('#linkType option:selected') .val()
                    };
                    this.$http.put('/restful/cms/v1.0/link/'+$('#linkId').val(),formData).then((response) => {
                        this.backToList();
                    }).catch(function(response) {
                        alert(errorMsg(response));
                    });
                }
            }
        });
    </script>
